package ged.diagram.edit.parts;

import org.eclipse.draw2d.Polygon;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.draw2d.geometry.Transform;

public class AggregationDecoration extends Polygon implements RotatableDecoration {

	public static final PointList TRIANGLE_TIP = new PointList();
	
	static {
		TRIANGLE_TIP.addPoint(1, 0);
		TRIANGLE_TIP.addPoint(0, 1);
		TRIANGLE_TIP.addPoint(0, -1);
		TRIANGLE_TIP.addPoint(-1, 0);
	}
	
	private Point location = new Point();
	private PointList template = TRIANGLE_TIP;
	private Transform transform = new Transform();
	
	public AggregationDecoration() {
		setFill(true);
		//setScale(7, 3);
	}
	
	
	public void setLocation(Point p) {
		//points = null;
		bounds = null;
		location.setLocation(p);
		transform.setTranslation(p.x, p.y);
	}
	
	public Rectangle getBounds() {
		if (bounds == null) {
			int expand = (int) (getLineWidthFloat() / 2.0f);
			bounds = getPoints().getBounds().getExpanded(expand, expand);
		}
		return bounds;
	}
	
	@Override
	public void setReferencePoint(Point p) {
		// TODO Auto-generated method stub
		
	}

}
